<!--
 * @Descripttion: 
 * @version: 
 * @Author: cyj
 * @Date: 2022-12-08 23:19:34
-->
<template>
    <div class="topnav">
        <el-menu router :default-active="defaultActive" mode="horizontal">
            <el-menu-item v-for="(item,index) in tabitem" :key="index" :index="item.path">
                {{item.name}}
            </el-menu-item>

        </el-menu>
    </div>
</template>

<script setup>
import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'
//数据区
const route = useRoute()
let defaultActive = ref('')

// props接收
defineProps({
    tabitem:{
        type:Array,
        default:[]
    }
})
//数据区

//方法区
function getPath() {
    //分割出path如：findmusic
    let PathArr = route.path
    defaultActive.value = PathArr
}
//监听路由的变化，路由发生变化 上来先执行一次，确定默认展示起作用
watch(route, () => {
    getPath()
},{immediate:true})

</script>

<style lang="scss" scoped>
.topnav {
    padding-left: 5px;
}

/* 发现音乐 顶部导航栏样式 */
.el-menu {
	border: 0;
}
.el-menu-item {
	color: #615f5f;
	height: 45px;
	line-height: 45px;
	font-size: 16px;
    margin: 0 5px;
}
.el-menu--horizontal > .el-menu-item.is-active {
	border-bottom: 3px solid var(--mycompColor);
	font-size: 18px;
	color: black !important;
}
.el-menu-item.is-active {
    background-color: none;
}
.el-menu--horizontal .el-menu-item:not(.is-disabled):focus, .el-menu--horizontal .el-menu-item:not(.is-disabled):hover {
    background-color: white;
    color: #000000;
}
</style>